﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Turtle8
{
    public partial class CompanyGearPanel : UserControl
    {
        private CompanyCard cCard;

        public CompanyGearPanel(CompanyCard cCard)
        {
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            this.cCard = cCard;

            CompanyGearPanel_Load(null, null);
            CompanyManager.setTableColumnHeadersHebrew(dataGridView.Columns);
            dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            refresh();

        }

        private void CompanyGearPanel_Load(object sender, EventArgs e)
        {
            showDataGridView();
        }

        public void refresh()
        {
            showDataGridView();
        }
        private void showDataGridView()
        {
            string selectStr = CompanyManager.getSqlStringFromFile(@"\SELECT\CompanyGear.SELECT.sql");
            SqlCommand selectCmd = new SqlCommand(selectStr, CompanyManager.Connection);

            DataTable dt = CompanyManager.selectSqlQueryDataTable(selectCmd);
            dataGridView.DataSource = dt;
            
            for (int i = 0; (i <= (dataGridView.Rows.Count - 1)); i++)
               dataGridView.Rows[i].HeaderCell.Value = string.Format((i + 1).ToString(), "0");

            dataGridView.Refresh();

           /* int rowNumber = 1;
            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.IsNewRow) continue;
                row.HeaderCell.Value = "Row " + rowNumber;
                rowNumber = rowNumber + 1;
            }
            dataGridView.AutoResizeRowHeadersWidth(
                DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);*/

        }
    }
}
